home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / TBaffleCommand.cp < prev    next >
Encoding:
Text File  |  1992-02-21  |  7.3 KB  |  201 lines  |  [TEXT/MPS ]

  1. #pragma segment Matrix
  2. // **********************************************************************
  3. //    TBaffleCommand - Methods
  4. // **********************************************************************
  5. // -------------------------------------------------------------------------------------------------
  6. //    TBaffleCommand Methods.
  7. // -------------------------------------------------------------------------------------------------
  8. // -------------------------------------------------------------------------------------------------
  9. // Initialize the TBaffleCommand.
  10. // -------------------------------------------------------------------------------------------------
  11. pascal void TBaffleCommand::IBaffleCommand (TGeomView * itsGeometry, TCFDFrontDocument * itsDocument, 
  12.     PointInfo * info, short tDirection)
  13.     {
  14.     fGeom             = itsGeometry;                                                                        // save geometry
  15.     fCDocument     = itsDocument;                                                                        // save document
  16.     fDirection        = tDirection;
  17.     fInfo.above    = info->above;
  18.     fInfo.right        = info->right;
  19.     fInfo.below    = info->below;
  20.     fInfo.left        = info->left;
  21.     ICommand (cMakeBaffle,fCDocument, fGeom, fGeom->GetScroller(true));
  22.     fConstrainsMouse = true;
  23.     }
  24.  
  25. // --------------------------------------------------------------------------------------------------
  26. //    Do it.
  27. // --------------------------------------------------------------------------------------------------
  28. pascal void TBaffleCommand::DoIt (void)
  29.     {
  30.     fBaffle = new TBaffle;
  31.     if (fBaffle == NULL)
  32.         {
  33.         SysBeep (3);
  34.         TWarning * tWarning;
  35.         TWindow    * aWindow;
  36.         
  37.         aWindow = NewTemplateWindow(kWarnMe, fCDocument);
  38.         tWarning = (TWarning *) aWindow->FindSubView('WARN');
  39.         tWarning->IWarning(6,"Baffle");
  40.         tWarning->ShowWarning();
  41.         return;
  42.         }
  43.         
  44.     HLock((Handle) this);
  45.     fBaffle->IBaffle(&fInfo,fDirection);                                                        // initialize Baffle
  46.     HUnlock((Handle) this);
  47.     fGeom->Focus();
  48.     fBaffle->Draw();                                                                                    // draw the Baffle
  49.     return;
  50.     }
  51.  
  52. // --------------------------------------------------------------------------------------------------
  53. //     Undo it.
  54. // --------------------------------------------------------------------------------------------------
  55. pascal void TBaffleCommand::UndoIt (void)
  56.     {
  57.     fGeom->Focus();
  58.     fBaffle->BaffleRelease();
  59.     fBaffle->Draw();
  60.     }
  61.  
  62. // --------------------------------------------------------------------------------------------------
  63. //     Redo it.
  64. // --------------------------------------------------------------------------------------------------
  65. pascal void TBaffleCommand::RedoIt (void)
  66.     {
  67.     fGeom->Focus();
  68.     fBaffle->BaffleSet();
  69.     fBaffle->Draw();
  70.     }
  71.  
  72. // --------------------------------------------------------------------------------------------------
  73. //     Commit BaffleCommand
  74. // --------------------------------------------------------------------------------------------------
  75. pascal void TBaffleCommand::TrackFeedback(VPoint * /*anchorPoint*/,VPoint * /*nextPoint*/, 
  76.     Boolean /*turnItOn*/, Boolean /*mouseDidMove*/)
  77.     {
  78.     fGeom->lastCmd = 1;
  79.     return;                                                                                                    // do nothing
  80.     }
  81.  
  82. // --------------------------------------------------------------------------------------------------
  83. //     Commit BaffleCommand
  84. // --------------------------------------------------------------------------------------------------
  85. pascal void TBaffleCommand::Commit (void)
  86.     {
  87.     fBaffle = NULL;                                                                                        // don't want to free the object
  88.     }
  89.  
  90. // --------------------------------------------------------------------------------------------------
  91. //     Free BaffleCommand
  92. // --------------------------------------------------------------------------------------------------
  93. pascal void TBaffleCommand::Free (void)
  94.     {
  95.     if (!fCmdDone)
  96.         FreeIfObject(fBaffle);
  97.     inherited::Free();
  98.     }
  99.  
  100. //**********************************************************************
  101. //    TDeleteBaffleCommand - Methods
  102. //**********************************************************************
  103. // -------------------------------------------------------------------------------------------------
  104. //    TDeleteBaffleCommand Methods.
  105. // -------------------------------------------------------------------------------------------------
  106. // -------------------------------------------------------------------------------------------------
  107. // Initialize the TDeleteBaffleCommand.
  108. // -------------------------------------------------------------------------------------------------
  109. Boolean TDeleteBaffleCommand::IDeleteBaffleCommand (TGeomView * itsGeometry, TCFDFrontDocument * itsDocument, 
  110.     PointInfo * info, short tDirection)
  111.     {
  112.     fGeom             = itsGeometry;                                                                        // save geometry
  113.     fCDocument     = itsDocument;                                                                        // save document
  114.     fInfo.right        = info->right;
  115.     fInfo.above    = info->above;
  116.     fInfo.left        = info->left;
  117.     fInfo.below    = info->below;
  118.     fDirection        = tDirection;
  119.     
  120.     if (fDirection == 1)
  121.         fBaffle = (TBaffle *) fInfo.above->fBaffBelow;
  122.     else
  123.         fBaffle = (TBaffle *) fInfo.left->fBaffRight;
  124.     SysBeep (3);
  125.  
  126.     Boolean            dismiss;
  127.     TWindow        * aWindow;
  128.     TWarnDelete    * dWarn;
  129.     char                message[80];
  130.      
  131.     sprintf(message,"Delete Baffle?");
  132.     aWindow = NewTemplateWindow(kWarnDelete, fCDocument);
  133.     if (aWindow == NULL)
  134.         return false;
  135.     dWarn = (TWarnDelete *) aWindow->FindSubView('delt');
  136.     dismiss = dWarn->ShowDelete(message);
  137.     if (!dismiss)
  138.         return false;
  139.         
  140.     ICommand (cDeleteBaffle,fCDocument, fGeom, fGeom->GetScroller(true));
  141.     fConstrainsMouse = true;
  142.     return true;
  143.     }
  144. // --------------------------------------------------------------------------------------------------
  145. //    Do it.
  146. // --------------------------------------------------------------------------------------------------
  147. pascal void TDeleteBaffleCommand::DoIt (void)
  148.     {
  149.     fGeom->Focus();
  150.     fBaffle->Draw();                                                                                // draw the Baffle
  151.     fBaffle->BaffleRelease();
  152.     return;
  153.     }
  154.  
  155. // --------------------------------------------------------------------------------------------------
  156. //     Undo it.
  157. // --------------------------------------------------------------------------------------------------
  158. pascal void TDeleteBaffleCommand::UndoIt (void)
  159.     {
  160.     fGeom->Focus();
  161.     fBaffle->Draw();
  162.     fBaffle->BaffleSet();
  163.     }
  164.  
  165. // --------------------------------------------------------------------------------------------------
  166. //     Redo it.
  167. // --------------------------------------------------------------------------------------------------
  168. pascal void TDeleteBaffleCommand::RedoIt (void)
  169.     {
  170.     fGeom->Focus();
  171.     fBaffle->Draw();
  172.     fBaffle->BaffleRelease();
  173.     }
  174.  
  175. // --------------------------------------------------------------------------------------------------
  176. //     Commit BaffleCommand
  177. // --------------------------------------------------------------------------------------------------
  178. pascal void TDeleteBaffleCommand::TrackFeedback(VPoint * /*anchorPoint*/,VPoint * /*nextPoint*/, 
  179.     Boolean /*turnItOn*/, Boolean /*mouseDidMove*/)
  180.     {
  181.     fGeom->lastCmd = 1;
  182.     return;                                                                                                    // do nothing
  183.     }
  184.  
  185. // --------------------------------------------------------------------------------------------------
  186. //     Commit BaffleCommand
  187. // --------------------------------------------------------------------------------------------------
  188. pascal void TDeleteBaffleCommand::Commit (void)
  189.     {
  190.     FreeIfObject(fBaffle);
  191.     }
  192.  
  193. // --------------------------------------------------------------------------------------------------
  194. //     Free BaffleCommand
  195. // --------------------------------------------------------------------------------------------------
  196. pascal void TDeleteBaffleCommand::Free (void)
  197.     {
  198.     inherited::Free();
  199.     }
  200.  
  201.